package com.itheima.aoc;


import com.itheima.service.LogService;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author 刘全
 * @date 2021/9/13
 */
@Component
@Aspect
public class LogActive {

    @Autowired
    private LogService logService;

    @Pointcut("execution(void com.itheima.service.AccountService.*(..))")
    public void logPt() {
    }

    @AfterThrowing("logPt()")
    public void method() {
        Date date = new Date();
        logService.save(date,"转账失败");
    }
}
